

#include "textureInspector.h"
#include "renderer.h"

TextureInspector::TextureInspector(){

    bOpen=false;
    bPermanent=true;
    initialLocation=location;
    tabWidth=350;
    listHeight=64;
    listWidth=64;
    listDisplayMode=4;
    listColumns=4;
    level=0;
    }

TextureInspector::~TextureInspector(){}


void TextureInspector::setup(){
ListButton::setup();

}

void TextureInspector::update(double deltaTime){}

void TextureInspector::mouseOver(){

ListButton::mouseOver();
}


void TextureInspector::drawPlane(){

    Button::drawPlane();

    renderer->setupShading("color");
    glColor3f(0.4,0.4,0.4);
    if (bOpen){
        renderer->drawPlane(scale.x ,0.0, scale.x+tabWidth,renderer->screenY, Vector4f(0.4,0.4,0.4, 1.0));
    }

}


void TextureInspector::mouseDrag(){}

void TextureInspector::clickedLeft(){

    if (!bOpen){
        initialLocation=location;
        location.x-=tabWidth;
        for (uint i=0;i<listButton.size();i++)
            listButton[i]->location.x+=location.x-initialLocation.x;
        bOpen=true;
        ListButton::clickedLeft();
    }
    else{
        for (uint i=0;i<listButton.size();i++)
            listButton[i]->location.x+=initialLocation.x-location.x;
        location=initialLocation;
        bOpen=false;
    }

    cout << "my listSize is: " << listButton.size() << endl;
}


void TextureInspector::assembleList(){

        cout << "creating list..." << endl;
        std::map <std::string, textureObject*>::iterator it;
        int i=0;

        for ( it=renderer->textureList.begin() ; it != renderer->textureList.end(); it++ ){

            renderer->actorInfo["20PropertyAssignButton"].actorReference->create();
            listButton.push_back(renderer->buttonList.back());

            listButton[i]->name="string " + it->first;
            listButton[i]->buttonProperty="TEXTUREID";
            listButton[i]->textureID="icon_base";
            listButton[i]->level=level+1;
            listButton[i]->bDrawName=false;
            listButton[i]->color=Vector4f(1,1,1,1.0);
            listButton[i]->textureID=it->first;
            listButton[i]->bPermanent=true;
            listButton[i]->bDragable=true;
            listButton[i]->setup();
            placeButton(i,i);
            //set this because we want to drag buttons around!
            listButton[i]->initialLocation=listButton[i]->location;

            i++;
        }

    cout << "our Button list is: "<< listButton.size() <<" elements long..." << endl;
}


void TextureInspector::clickedRight(){}
void TextureInspector::focusClick(){

ListButton::focusClick();
}

void TextureInspector::deselect(int depth){

//ListButton::deselect(depth);
}

void TextureInspector::create(){renderer->addButton(this);}
